package com.jk.smartelderlycare.utils;

import com.jk.smartelderlycare.pojo.PagedResponse;

import java.util.List;

public class PaginationUtil{
   public static <T> PagedResponse<T> getPagedResponse(List<T> items, Integer pageNum, Integer pageSize, long total) {
       PagedResponse<T> response = new PagedResponse<>();
       response.setItems(items);
       response.setPageNum(pageNum);
       response.setPageSize(pageSize);
       response.setTotal(total);
       response.setTotalPages((int)Math.ceil((double)total/pageSize));
       return response;
   }
}